package com.sicheng.hello.service.impl;

import com.sicheng.hello.service.Job;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author zsc
 * @version 1.0
 * @date 2021/10/8 22:38
 */
@Slf4j
@Component
public class JobService implements Job {
    private final AtomicInteger counts = new AtomicInteger(0);

    @Scheduled(fixedRate = 1000)
    @Override
    public void execute() {
        log.info("[execute][定时第 {} 次执行]", counts.incrementAndGet());
    }

    @Scheduled(fixedRate = 2 * 1000)
    public void execute1() {
        log.info("[execute][定时第 {} 次执行]", counts.incrementAndGet());
    }
}
